<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Model\{Usertree};

class batch_addnodes extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'songshu:batch_add';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '批量注册节点';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
       # Usertree::add(4,1);
        dd(DB::table('user_tree')->where([
            ['tree_id','=',0],
            ['right','=',0],
            ['pid','>',0]
        ])->count());
        $list = DB::table('user_tree')->where([
            ['tree_id','=',0],
            ['right','=',0],
            ['pid','>',0]
        ])->limit(100)->get()->toArray();

        dd($list);
        foreach($list as $item){
            Usertree::add($item->uid,$tiem->pid);
        }
    }
}
